package com.qf.bean;

import com.qf.entity.TProduct;

import java.io.Serializable;
import java.util.LinkedList;
import java.util.List;

public class CartInfo implements Serializable {
    static final java.text.DecimalFormat df=new java.text.DecimalFormat("#.00");

    private List<TProduct> productList;
    private String amount;
    private int totalExchangeScore;

    private List<Address> addressList;
    @Deprecated
    private Address address;
    private String defaultAddressID;

    public List<TProduct> getProductList() {
        if (productList == null) {
            productList=new LinkedList<TProduct>();
        }
        return productList;
    }

    public void setProductList(List<TProduct> productList) {
        this.productList = productList;
    }

    public String getAmount() {
        return amount;
    }

    public void setAmount(String amount) {
        this.amount = amount;
    }

    public int getTotalExchangeScore() {
        return totalExchangeScore;
    }

    public void setTotalExchangeScore(int totalExchangeScore) {
        this.totalExchangeScore = totalExchangeScore;
    }

    public List<Address> getAddressList() {
        return addressList;
    }

    public void setAddressList(List<Address> addressList) {
        this.addressList = addressList;
    }

    public String getDefaultAddressID() {
        return defaultAddressID;
    }

    public void setDefaultAddressID(String defaultAddressID) {
        this.defaultAddressID = defaultAddressID;
    }

    public Address getAddress() {
        if (address == null) {
            address=new Address();
        }
        return address;
    }

    public void setAddress(Address address) {
        this.address = address;
    }

    public void totalCacl(){
        double _amount=0;
        int _totalExchangeScore=0;
        for (int i = 0; i < getProductList().size(); i++) {
            TProduct product = getProductList().get(i);
        }

        this.totalExchangeScore=_totalExchangeScore;
        if(_amount!=0){
            this.amount=df.format(_amount);
        }else {
            this.amount="0.00";
        }
    }

    @Override
    public String toString() {
        return "CartInfo{" +
                "productList=" + productList +
                ", amount='" + amount + '\'' +
                ", totalExchangeScore=" + totalExchangeScore +
                ", addressList=" + addressList +
                ", address=" + address +
                ", defaultAddressID='" + defaultAddressID + '\'' +
                '}';
    }
}
